<template>
  <div>
    <!-- 详细信息 -->
    <workPermitDetail :reportId="reportId"></workPermitDetail>
    <a-divider></a-divider>
    <view>
      <a-input style="margin-left: 10px; width: 80%;" v-model:value="paramFlow.remark" :rows="1" type="textarea"
        placeholder="批复意见" />
      <a-button type="primary" danger @click="getReject" style="margin-left: 30px">驳回</a-button>
      <a-button type="primary" @click="getComplete" style="margin-left: 10px">通过</a-button>
    </view>
    <a-divider></a-divider>
    <!-- 签名组件 -->
    <xnSignName style="margin-left: 30px; width: 80vh;"></xnSignName>
    <!-- <signature-features /> -->
  </div>
</template>
<script setup>
import workPermitDetail from '../detail';
import signatureFeatures from '@/custom/salvage/components/signatureFeatures/signatureFeatures.vue'
import xnSignName from '@/custom/salvage/components/signatureFeatures/xnSignName.vue';
import FlowTasks from '@/api/flow/tasks'
import useApp from "@/hooks";
const { $, proxy } = useApp();
const props = defineProps({
  flowData: {
    type: Object
  }
})
const emit = defineEmits(["operate"]);
const reportId = ref()
const paramFlow = ref({
  flowWorkId: "",
  remark: ""
})
watch(() => props.flowData, () => {
  console.log('watch--flowData', props.flowData);
  getData()
}, { deep: true });

function getData() {
  console.log('props.flowData', props.flowData);
  reportId.value = props.flowData.businessId
  paramFlow.value.flowWorkId = props.flowData.id
}
getData()
// 通过
function getComplete() {
  // console.log('paramFlow.value', paramFlow.value);
  FlowTasks.doComplete(paramFlow.value).then(res => {
    $.showToast({
      title: '已通过',
      icon: 'success'
    })
    emit('operate')
    // console.log(res);
  })
}
// 驳回
function getReject() {
  // console.log('paramFlow.value', paramFlow.value);
  FlowTasks.doReject(paramFlow.value).then(res => {
    $.showToast({
      title: '已驳回',
      icon: 'warn'
    })
    emit('operate')
    // console.log(res);
  })
}
</script>